package com.richapp.launcher.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.richapp.launcher.R;

public class ChildRoomScenarioGridAdapter extends BaseAdapter {
	int imageID[]={R.drawable.writing_model,R.drawable.exclusive_mode,R.drawable.magic_mode,
			       R.drawable.happy_mode,R.drawable.eating_model,R.drawable.leisure_model,
			       R.drawable.love_model,R.drawable.film_model};
	String testData[];
    LayoutInflater layoutInflater = null;
	public ChildRoomScenarioGridAdapter(Context context){
		layoutInflater = LayoutInflater.from(context);
		testData = context.getResources().getStringArray(R.array.roomscenario);

	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 8;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	boolean flag = true;
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = layoutInflater.inflate(R.layout.child_gridroomscenario_item,null);
			viewHolder.scenario_grid_title = (TextView)convertView.findViewById(R.id.scenario_grid_title);
			viewHolder.child_scenario = (ImageView)convertView.findViewById(R.id.child_scenario);
		    convertView.setTag(viewHolder);
		}else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.child_scenario.setImageResource(imageID[position]);
		viewHolder.scenario_grid_title.setText(testData[position]);
		return convertView;
	}

	class ViewHolder{
		TextView scenario_grid_title = null;
		ImageView child_scenario = null;
	}
}
